<!DOCTYPE html>
<!--[if IE 8]> <html lang="en" class="ie8 no-js"> <![endif]-->
<!--[if IE 9]> <html lang="en" class="ie9 no-js"> <![endif]-->
<!--[if !IE]><!-->
<html lang="en" class="no-js">
<!--<![endif]-->
<!-- BEGIN HEAD -->
<head>
<meta charset="utf-8" />
<title>数据统计 - 销售走势</title>
<?php include($this->c['_homes']['_viewsHome'].'/_global/_head.php');?>
</head>
<!-- BEGIN BODY -->
<body class="page-header-fixed page-sidebar-fixed">
<!-- BEGIN HEADER -->
<?php include($this->c['_homes']['_viewsHome'].'/_global/head.php');?>
<!-- END HEADER -->
<div class="clearfix"></div>
<!-- BEGIN CONTAINER -->
<div class="page-container" > 
  <!-- BEGIN HORIZONTAL MENU PAGE SIDEBAR1 -->
  <?php include($this->c['_homes']['_viewsHome'].'/_global/menu.php');?>
  <!-- END BEGIN HORIZONTAL MENU PAGE SIDEBAR --> 
  <!-- BEGIN PAGE --> 
  <div class="page-content"> 
    <!-- BEGIN PAGE HEADER-->
    <div class="row">
      <div class="col-md-12"> 
        <!-- BEGIN PAGE TITLE & BREADCRUMB-->
        <h3 class="page-title"> 销售走势</h3>
        <ul class="page-breadcrumb breadcrumb">
          <li> <i class="icon-home"></i> <a href="/manage">后台</a> <i class="icon-angle-right"></i> </li>
          <li>数据分析<i class="icon-angle-right"></i></li>
          <li>销售走势</li>
        </ul>
        <!-- END PAGE TITLE & BREADCRUMB--> 
      </div>
    </div>
    <!-- END PAGE HEADER--> 
    <!-- BEGIN DASHBOARD STATS -->
    <div class="row">
           <div class="col-md-12">
            <form method="get" role="form" action="" onSubmit="return chkfrm();">
<!--              <div class="col-md-3">                  
                  <select class="form-control" name="storeid">
                    <option value="">全部门店</option>
                    <?php 
                    	if($this->store){
                    		foreach($this->store as $v){
                    ?>
                    <option value="<?=$v['storeid']?>" <?php if($_GET['storeid']==$v['storeid']){echo selected;}?>><?=$v['name']?></option>
                    <? }}?>
                 </select>
                </div> -->
            <div class="col-md-6">
              <div style="width:550px;float:left;margin:0 15px;">
                    <div class="input-group input-medium date date-picker" data-date="<?=date("Y-m-d");?>" data-date-format="yyyy-mm-dd" data-date-viewmode="years" data-date-minviewmode="months" style="float:left;">
                      <input class="form-control" readonly="" type="text" placeholder="开始时间" id="start_time" name="start_time" value="<?php if(isset($_GET['start_time'])){echo $_GET['start_time'];}else{echo '起始时间' ;} ?>">
<!--                       <span class="input-group-btn"> -->
<!--                          <button class="btn default date-reset" type="button"><i class="icon-remove"></i></button> -->
<!--                       </span>  -->
                      <span class="input-group-btn">
                      <button type="button" class="btn default date-set"><i class="icon-calendar"></i></button>
                      </span> </div>
                    <span style="color:#666;width:60px;line-height:34px;padding-left:20px;float:left;">- 至 -</span>
                    <div class="input-group input-medium date date-picker" data-date="<?=date("Y-m-d");?>" data-date-format="yyyy-mm-dd" data-date-viewmode="years" data-date-minviewmode="months" style="float:right;">
                      <input class="form-control" readonly="" type="text" placeholder="结束时间" id="end_time" name="end_time" value="<?php if(isset($_GET['end_time'])){echo $_GET['end_time'];}else{echo '结束时间' ;} ?>">
<!--                       <span class="input-group-btn"> -->
<!--                          <button class="btn default date-reset" type="button"><i class="icon-remove"></i></button> -->
<!--                       </span>  -->
                      <span class="input-group-btn">
                      <button type="button" class="btn default date-set"><i class="icon-calendar"></i></button>
                      </span> </div>
                  </div>
                  </div>
                  <div class="col-md-1"></div>
                  <div class="col-md-2">
                    <input type="submit" value="搜 索" class="btn blue btn-block">
                  </div>
            </form>
         </div>
       </div>
    <div class="row">
      <div class="col-md-12 col-sm-12">
      <div id="container_order" style="width:100%;height:400px;margin-top:30px;">订单数据加载中...</div>
      </div>
    </div>
  </div>
  <!-- END PAGE --> 
</div>
<!-- END CONTAINER -->
<?php include($this->c['_homes']['_viewsHome'].'/_global/_footer.php');?>
<script type="text/javascript" src="/style/chart/highcharts.js"></script>
<script type="text/javascript" src="/style/chart/exporting.js"> </script>
<!-- BEGIN PAGE LEVEL SCRIPTS --> 
<script src="/style/assets/scripts/app.js" type="text/javascript"></script> 
<!-- END PAGE LEVEL SCRIPTS --> 
<script>
jQuery(document).ready(function() {    
   App.init();

   if (jQuery().datepicker) {
	      $('.date-picker').datepicker({
	          rtl: App.isRTL(),
	          autoclose: true
	      });
	      $('body').removeClass("modal-open"); // fix bug when inline picker is used in modal
	    } 
});

$(function () {
	 $('#container_order').highcharts({
         chart: {
             zoomType: 'xy'
         },
         title: {
             text: '<?=$this->chart['date'];?>订单与销售额走势'
         },
         subtitle: {
             text: '<?=$this->chart['start'];?>~<?=$this->chart['end'];?>'
         },
         credits: {
         	enabled:false // 禁用版权信息
         },
         xAxis: [{
         	categories:[<?php foreach ($this->chart['date_time'] as $k=>$v){
         		echo "'".$v."',";
         	}?>],
             crosshair: true
         }],
         yAxis: [{ // Primary yAxis
             labels: {
                 format: '{value}',
                 style: {
                     color: Highcharts.getOptions().colors[1]
                 }
             },
             title: {
                 text: '百分比',
                 style: {
                     color: Highcharts.getOptions().colors[1]
                 }
             }
         }, { // Secondary yAxis
             title: {
                 text: '数量(单/元)',
                 style: {
                     color: Highcharts.getOptions().colors[0]
                 }
             },
             labels: {
                 format: '{value}',
                 style: {
                     color: Highcharts.getOptions().colors[0]
                 }
             },
             opposite: true
         }],
         tooltip: {
             headerFormat: '<span>月份：{point.key}</span><br/>',
             shared: true,
             useHTML: true
         },
         plotOptions: {
             column: {
                 pointPadding: 0.2,
                 borderWidth: 0,

             }
         },
         series: [{
        	 name: '已付款订单数',
             type: 'column',
             yAxis: 1,
             data: [<?php foreach ($this->chart['date_time'] as $k=>$v){
           		echo $this->chart['order']['payed']['count'][$v].",";
           	}?>],
             tooltip: {
                 valueSuffix: ' 单'
             }

         },{
        	 name: '未付款订单数',
             type: 'column',
             yAxis: 1,
             data: [<?php foreach ($this->chart['date_time'] as $k=>$v){
         		echo $this->chart['order']['unpay']['count'][$v].",";
         	}?>],
             tooltip: {
                 valueSuffix: ' 单'
             }

         }, {
        	 name: '已付款金额',
             type: 'column',
             yAxis: 1,
             data: [<?php foreach ($this->chart['date_time'] as $k=>$v){
         		echo $this->chart['order']['payed']['money'][$v].",";
         	}?>],
             tooltip: {
                 valueSuffix: '元'
             }

         }, {
        	 name: '未付款金额',
             type: 'column',
             yAxis: 1,
             data: [<?php foreach ($this->chart['date_time'] as $k=>$v){
           		echo $this->chart['order']['unpay']['money'][$v].",";
           	}?>],
             tooltip: {
                 valueSuffix: '元'
             }

         }, {
             name: '同比上月订单数增长率',
             type: 'spline',
             data:  [<?php foreach ($this->chart['date_time'] as $k=>$v){
         		echo $this->chart['order']['total']['ratescount'][$v].",";
         	}?>],
             tooltip: {
                 valueSuffix: '%'
             }
         },{
             name: '同比上月销售金额增长率',
             type: 'spline',
             data:  [<?php foreach ($this->chart['date_time'] as $k=>$v){
           		echo $this->chart['order']['total']['ratesmoney'][$v].",";
           	}?>],
             tooltip: {
                 valueSuffix: '%'
             }
         }]
     });
});
</script> 
<script>
function chkfrm(){
	var start_time = document.getElementById("start_time").value;
	var end_time = document.getElementById("end_time").value;
	start_time = start_time.replace(/-/g,'/');
	end_time = end_time.replace(/-/g,'/');
	var date_start_time = new Date(start_time);
	var date_end_time = new Date(end_time);
	if(date_start_time !="" && date_end_time != ""&& date_start_time > date_end_time){
         alert("开始时间不能大于结束时间");
         return false;
	}
}
</script>
<!-- END JAVASCRIPTS -->
</body>
<!-- END BODY -->
</html>